<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of category
 *
 * @author Bui Van Thien
 */
class Model_Category extends \Orm\Model
{

    protected static $_properties = array(
        'id',
        'user_id',
        'name',
        'description',
        'parent_id',
        'type',
        'created',
        'updated'
    );
    protected static $_observer = array(
        'Orm/Observer_Created_At'=>array(
            'events'=>array('before_insert'),
            'mysql_timestamp'=>true,
            'property'=>'created'
        ),
        'Orm/Onserver_Updated_At'=>array(
            'events'=> array('before_save'),
            'mysql_timestamp'=>true,
            'property'=>'updated'
        )
    );
    protected static $_table_name = 'tb_categories';
    protected static $_belong_to = array(
        'user'=>array(
            'key_from'  =>  'id',
            'model_to'  =>  'Model_User',
            'key_to'    =>  'user_id'
        )
    );
    protected static $_has_many = array(
        'transaction'=>array (
            'key_from'  =>  'category_id',
            'model_to'  =>  'Model_Transaction',
            'key_to'    =>  'id'
        )
    );

}
